using System;
using System.ComponentModel.Design;
using System.Reflection;
using Microsoft.WowAddonStudio.Lua.LanguageService.Tests.WowCommonTestLibrary.Mocks;
using Microsoft.WowAddonStudio.Project;
using NUnit.Framework;
using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;

namespace WowProjectPackage.Tests
{
	[TestFixture]
	public class WowProjectFactoryTest
	{
		#region SetUp

		[SetUp]
		public void SetUp()
		{

		}

		#endregion

		#region TearDown

		[TearDown]
		public void TearDown()
		{

		}

		#endregion

		#region Tests

		[Test(Description = "")]
		public void Test_CreateProject()
		{
			var serviceLocator = new SimpleTestServiceLocator();

			var package = new Microsoft.WowAddonStudio.Project.WowProjectPackage();
			((IServiceContainer)package).AddService(typeof(IOleServiceProvider), serviceLocator);

			var service = (((IServiceProvider) package).GetService(typeof (IOleServiceProvider)));

			Assert.IsNotNull(service);

			var factory = new WowProjectFactory(package);

			var method = typeof(WowProjectFactory).GetMethod("CreateProject", 
			                                                 BindingFlags.NonPublic | BindingFlags.Instance,null, CallingConventions.Any,new Type[0], null );
			Assert.IsNotNull(method);

			var result = method.Invoke(factory, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, 
				null, new object[0], null);
			Assert.IsNotNull(result);
			Assert.IsInstanceOfType(typeof(WowProjectNode), result);
		}

		#endregion
	}
}